
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
"When regular expressions are just too hard!"
Match glob expressions using * and ? against any JavaScript data type. The character * means match anything of any length, the character ? means match exactly one of any character, and all other characters match themselves.
const { Gex } = require('gex')
Gex('a*').on( 'abc' ) // returns 'abc'
Gex('a*c').on( 'abbbc' ) // returns 'abbbc'
Gex('a?c').on( 'abc' ) // returns 'abc'
You can also match against objects and arrays:
Gex('a*').on( ['ab','zz','ac'] ) // returns ['ab','ac']
Gex('a*').on( {ab:1,zz:2,ac:3} ) // returns {ab:1,ac:3}
And also match against multiple globs:
Gex(['a*','b*']).on( 'bx' ) // returns 'bx'
Gex(['a*','b*']).on( ['ax','zz','bx'] ) // returns ['ax','bx']
One of the most useful things you can do with this library is quick
assertions in unit tests. For example if your objects contain dates,
randomly generated unique identifiers, or other data irrelevant for
testing, Gex
can help you ignore them when you use JSON.stringify
:
var entity = {created: new Date().getTime(), name:'foo' }
assert.ok( Gex('{"created":*,"name":"foo"}').on( JSON.stringify(entity) ) )
If you need to use globbing on files, here's how apply a glob to a list of files in a folder:
var fs = require('fs')
fs.readdir('.',function(err,files){
var pngs = Gex('*.png').on(files)
})
And that's it!
npm install gex
And in your code:
const { Gex } = require('gex')
Or clone the git repository: git clone git://github.com/rjrodger/gex.git
This library depends on the excellent underscore module: underscore
The Gex
object is a function that takes a single argument, the glob
expression. This returns a Gex
object that has only one function
itself: on
. The on
function accepts any JavaScript data type, and operates as follows:
If you're using this library, feel free to contact me on twitter if you have any questions! :) @rjrodger
This module works on both Node.js and browsers.
Copyright (c) 2010-2020, Richard Rodger and other contributors. Licensed under MIT.
FAQs
Glob expressions for JavaScript
The npm package gex receives a total of 5,775 weekly downloads. As such, gex popularity was classified as popular.
We found that gex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.